package api

import (
	"fmt"
	"net/http"
	"zuoyei1/api-getaway/handler/request"

	"github.com/gin-gonic/gin"
)

func Login(context *gin.Context) {

	var loginRequest request.LoginRequest
	if err := context.ShouldBindJSON(&loginRequest); err != nil {
		context.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
		return
	}
	fmt.Println(loginRequest)

	context.JSON(http.StatusOK, gin.H{
		"status": "登陆成功",
		"code":   http.StatusOK,
		"data":   loginRequest,
	})

}

func Add(context *gin.Context) {

	var AddRequest request.LoginRequest
	if err := context.ShouldBindJSON(&AddRequest); err != nil {
		context.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
		return
	}
	fmt.Println(AddRequest)

	context.JSON(http.StatusOK, gin.H{
		"status": "注册成功",
		"code":   http.StatusOK,
		"data":   AddRequest,
	})

}
